<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .box{
            margin: 50px auto;
            width: 360px;
            padding-top: 360px;
            border: 1px solid #ccc;
            background: url('./01big.jpg') no-repeat;
        }
        .box>ul{
            height: 70px;
            list-style: none;
            border-top: 1px solid #ccc;
        }
        .box>ul>li{
            float: left;
            
        }
        .box>ul>li>img{
            cursor: pointer;
        }
    </style>
</head>
<body>
    <div class="box">
        <ul>
            <li><img src="./01.jpg" alt="商品图片"></li>
            <li><img src="./02.jpg" alt="商品图片"></li>
            <li><img src="./03.jpg" alt="商品图片"></li>
            <li><img src="./04.jpg" alt="商品图片"></li>
            <li><img src="./05.jpg" alt="商品图片"></li>
        </ul>
    </div>
</body>
<script>
    var box = document.querySelector('div');
    var img = document.querySelectorAll('img');
//平常使用
    // for (let index = 0; index < img.length; index++) {
    //     img[index].onmouseover = function () {
    //         box.style.background = 'url(./0'+(index+1)+'big.jpg) no-repeat';
    //     }
        
    // }

//es6使用
    img.forEach((item,index) => {
        item.onmouseover = function(){
            box.style.background = 'url(./0'+(index+1)+'big.jpg) no-repeat';
        }
    })
</script>
</html>